var e = require;
var t = module;
cc.Class({
    extends: cc.Component,
    properties: {subNames: [cc.String], nextSceneName: "Main"},
    start: function start() {
        var e = this;
        this.loadArraySubPackage(
            this.subNames,
            function () {
                cc.director.loadScene(e.nextSceneName);
            },
            function () {
                console.error("分包加载失败！"), cc.director.loadScene(e.nextSceneName);
            }
        );
    },
    loadArraySubPackage: function loadArraySubPackage(e, t, o, n, i) {
        void 0 === i && (i = 0);
        var a = this;
        e &&
            e.length > 0 &&
            this.loadSubPackage(
                e[i],
                function () {
                    ++i >= e.length ? t && t() : a.loadArraySubPackage(e, t, o, n, i);
                },
                function (e) {
                    o && o(e), console.error("loadArraySubPackage:" + JSON.stringify(e));
                },
                function (e) {
                    n && n(e);
                }
            );
    },
    loadSubPackage: function loadSubPackage(e, t, o) {
        var n = null;
        if (cc.assetManager && cc.assetManager.loadBundle)
            n = cc.assetManager.loadBundle(e, null, function (e, n) {
                e ? o && o(e) : t && t(n);
            });
        else {
            var i = (
                window.ks ||
                window.kwaigame ||
                window.wx ||
                window.qg ||
                window.swan ||
                window.tt ||
                window.qq
            ).loadSubpackage({
                name: e,
                success: function success(e) {
                    t && t(e);
                },
                fail: function fail(e) {
                    o && o(e);
                }
            });
            i.onProgressUpdate(function () {}), (n = i);
        }
        return n;
    }
});
